﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace gt.dotnetcore.configuration
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureAppConfiguration((context, config) =>
                {
                    //config.SetBasePath(Directory.GetCurrentDirectory());//如果iis调试，请注释
                    config.AddJsonFile("appsettings_ext.json", optional: false, reloadOnChange: false);
                })
                .UseStartup<Startup>();
    }


    public class AsyncTest
    {
        private async Task<string> Run1()
        {
            await Task.Delay(3000);
            await Task.Delay(2000);
            Console.WriteLine(DateTime.Now.ToLongTimeString() + " run1 ok");
            return "run1 ok";
        }
        private async Task<string> Run2()
        {
            await Task.Delay(2000);
            Console.WriteLine(DateTime.Now.ToLongTimeString() + " run2 ok");
            return "run2 ok";
        }

        public void Run()
        {
            var t1 = Run1();
            var t2 = Run2();
            Task.WaitAll(t1, t2);
            Console.WriteLine(t1.Result);
            Console.WriteLine(t2.Result);
        }
    }
}
